package com.seednia.module.core.user.service.ws;

import java.util.List;

import javax.jws.WebService;

import com.seednia.foundation.framework.dto.QueryParams;
import com.seednia.foundation.framework.service.RemoteException;
import com.seednia.module.core.resource.dto.MediaDto;
import com.seednia.module.core.user.dto.UserCriteria;
import com.seednia.module.core.user.dto.UserDto;

/**
 * Interface for the User web service
 * 
 * @author Young Suk Ahn
 *
 */
@WebService
public interface IUserWebService  {

	/**
	 * 
	 * @param accessToken
	 * @param xid
	 * @return
	 * @throws RemoteException
	 */
	UserDto getUser(String accessToken, String xid) throws RemoteException;
	
	/**
	 * Lists the User
	 * @param criteria  The criteria used to retrieve the list (considered fields: )
	 * @return The list of records based on the criteria
	 * @throws RemoteException
	 */
	List<UserDto> getUserList(String accessToken, UserCriteria criteria, QueryParams params) throws RemoteException;
	
	/**
	 * Inserts a User
	 * @param record 	The record to be inserted
	 * @return the SID of the newely inserted record
	 * @throws RemoteException
	 */
	Long insertUser(String accessToken, UserDto record)  throws RemoteException;
	
	/**
	 * Updates a User
	 * @param record	The record to be updated. Pre condition: all the values must be valid
	 * @return 			The number of affected rows
	 * @throws RemoteException
	 */
	int updateUser(String accessToken, UserDto record) throws RemoteException;
	
	/**
	 * Deletes a User
	 * @param criteria	The criteria used to delete in the table (considered fields: )
	 * @return			The number of affected rows
	 * @throws RemoteException
	 */
	int deleteUser(String accessToken, UserCriteria criteria) throws RemoteException;
	
	////////// Additional Business Operations //////////
	
	int updateActiveProject(String accessToken, long userSid, long activeProjectSid) throws RemoteException;
	
	/**
	 * Changes the user's profile image to the one provided.
	 * If the media has SID then it's an existing one, just update the profileImage's SID
	 * Otherwise, its a newly uploaded file, create a media entry and assign the SID as the
	 * profileImage SID.
	 * 
	 * @param accessToken
	 * @param domainSid
	 * @param which "profile" or "cover"
	 * @param media
	 * @return
	 * @throws RemoteException
	 */
	int updateUserProfileImage(String accessToken, long userSid, String which, MediaDto media) throws RemoteException;

}
